<?
class graphWindowsDeviceMemoryUsage  extends graphBase {
	public function getOptions() {
		$opts = array();
		$physicalMemoryUsed = array();
		$physicalMemorySize = array();
		$physicalPluses = array();
		
		$virtualMemoryUsed = array();
		$virtualMemorySize = array();
		$virtualPluses = array();
		
		foreach ($this->device->memory AS $memory) {
			switch($memory->type) {
				case 'hrStorageVirtualMemory':
					$opts[] = 'DEF:memory_'.$memory->index.'_used='.$this->rrdPath.'storage_'.$memory->index.'.rrd:used:AVERAGE';
					$opts[] = 'DEF:memory_'.$memory->index.'_size='.$this->rrdPath.'storage_'.$memory->index.'.rrd:size:AVERAGE';
					$virtualMemoryUsed[] = 'memory_'.$memory->index.'_used';
					$virtualMemorySize[] = 'memory_'.$memory->index.'_size';
					$virtualPluses[] = '+';
					break;
				case 'hrStorageRam':
					$opts[] = 'DEF:memory_'.$memory->index.'_used='.$this->rrdPath.'storage_'.$memory->index.'.rrd:used:AVERAGE';
					$opts[] = 'DEF:memory_'.$memory->index.'_size='.$this->rrdPath.'storage_'.$memory->index.'.rrd:size:AVERAGE';
					$physicalMemoryUsed[] = 'memory_'.$memory->index.'_used';
					$physicalMemorySize[] = 'memory_'.$memory->index.'_size';
					$physicalPluses[] = '+';
					break;
			
			}
		}
		if (sizeof($physicalPluses) > 1) {
			$opts[] = 'CDEF:memory_used='.implode(',',$physicalMemoryUsed).','.implode(',',$physicalPluses);
			$opts[] = 'CDEF:memory_size='.implode(',',$physicalMemorySize).','.implode(',',$physicalPluses);
		} else {
			$opts[] = 'CDEF:memory_used='.implode(',',$physicalMemoryUsed);
			$opts[] = 'CDEF:memory_size='.implode(',',$physicalMemorySize);
		}
		if (sizeof($virtualPluses) > 1) {
			$opts[] = 'CDEF:swap_used='.implode(',',$virtualMemoryUsed).','.implode(',',$virtualPluses).',-1,*';
			$opts[] = 'CDEF:swap_size='.implode(',',$virtualMemorySize).','.implode(',',$virtualPluses).',-1,*';
		} else {
			$opts[] = 'CDEF:swap_used='.implode(',',$virtualMemoryUsed);
			$opts[] = 'CDEF:swap_size='.implode(',',$virtualMemorySize);
			$opts[] = 'CDEF:dswap_used='.implode(',',$virtualMemoryUsed).',-1,*';
			$opts[] = 'CDEF:dswap_size='.implode(',',$virtualMemorySize).',-1,*';

		}
		
		$opts[] = 'AREA:dswap_size#C3D9FF33';
		$opts[] = 'LINE1.25:dswap_size#000:Swap Total   ';
		$opts[] = 'GPRINT:swap_size:LAST:  %7.2lf%sB';
		$opts[] = 'GPRINT:swap_size:AVERAGE:        %7.2lf%sB';
		$opts[] = 'GPRINT:swap_size:MAX:       %7.2lf%sB\n';
		
		$opts[] = 'AREA:dswap_used#C3D9FF';
		$opts[] = 'LINE1.25:dswap_used#356AA0:Swap Used   ';
		$opts[] = 'GPRINT:swap_used:LAST:   %7.2lf%sB';
		$opts[] = 'GPRINT:swap_used:AVERAGE:        %7.2lf%sB';
		$opts[] = 'GPRINT:swap_used:MAX:       %7.2lf%sB\n';


		$opts[] = 'AREA:memory_used#fcc';
		$opts[] = 'LINE1.25:memory_used#ff1a00:Memory Used   ';
		$opts[] = 'GPRINT:memory_used:LAST: %7.2lf%sB';
		$opts[] = 'GPRINT:memory_used:AVERAGE:        %7.2lf%sB';
		$opts[] = 'GPRINT:memory_used:MAX:       %7.2lf%sB\n';

		$opts[] = 'AREA:memory_size#ffcccc33';
		$opts[] = 'LINE1.25:memory_size#000:Memory Total ';
		$opts[] = 'GPRINT:memory_size:LAST:  %7.2lf%sB';
		$opts[] = 'GPRINT:memory_size:AVERAGE:        %7.2lf%sB';
		$opts[] = 'GPRINT:memory_size:MAX:       %7.2lf%sB\n';
		$opts[] = 'COMMENT:Memory               Current            Average           Maximum\n';
		return $opts;
	}
}